package cn.chendd.bless.service.impl;

import cn.chendd.bless.mapper.GoodLuckMapper;
import cn.chendd.bless.model.GoodLuck;
import cn.chendd.bless.service.GoodLuckService;
import io.seata.core.context.RootContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 新年好运 Service接口实现
 *
 * @author chendd
 * @date 2023/1/23 20:54
 */
@Service
public class GoodLuckServiceImpl implements GoodLuckService {

    @Resource
    private GoodLuckMapper goodLuckMapper;

    @Override
    public void saveData() {
        System.out.println("TX_XID--->" + RootContext.getXID());
        GoodLuck goodLuck = new GoodLuck(null , "chendd" , "新的一年展翅高飞！");
        this.goodLuckMapper.insert(goodLuck);
    }

    @Override
    public void saveDataException() {
        System.out.println("TX_XID--->" + RootContext.getXID());
        this.saveData();
        throw new NullPointerException("【Bluess】自定义空指针异常抛出");
    }
}
